package com.example.springdemo;

import org.springframework.util.StringUtils;

public class ListTest {
    public static void main(String[] args) {
        System.out.println( engineeringTreasureWIFIwFlag("GCBWiFi12sss3456"));

    }
    public static boolean engineeringTreasureWIFIwFlag(String wifiName) {
        // 校验规则：GCBWiFi+MAC地址后六位
        if (StringUtils.isEmpty(wifiName)){
            return false;
        }

        if (wifiName.length() != 13){
            return false;
        }

        String wifiNameStartHalf = wifiName.substring(0,7);
        String wifiNameEndHalf = wifiName.substring(7,13);
        System.out.println(wifiNameStartHalf);
        System.out.println(wifiNameEndHalf);
        // 判断前半段是否为 GCBWiFi
        boolean wifiNameStartHalfPass = "GCBWiFi".equals(wifiNameStartHalf);
        // 判断后半段是否为 数字
        boolean wifiNameEndHalfPass = true;
        for (int i = 0; i < wifiNameEndHalf.length(); i++){
            if (!Character.isDigit(wifiNameEndHalf.charAt(i))){
                wifiNameEndHalfPass = false;
                break;
            }
        }
        if (wifiNameStartHalfPass && wifiNameEndHalfPass){
            return true;
        }else {
            return false;
        }

    }
}


